#include<iostream>
#include<cstdio>
using namespace std; 
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	int a,b,n,m,p,q;
	cin>>n>>a>>b;
	p=a%n;
	q=b%n;
	if(p>=q)cout<<n-1;
	else
	{
		if((b-a)>n)cout<<n-1;
		else cout<<q;
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
